package m.jclecai.com.adapter.channel;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.List;

import m.jclecai.com.R;
import m.jclecai.com.bean.home.Sub;

/**
 *  我的频道适配器
 */
public class MyChannelAdapter  extends BaseAdapter {

    private List<Sub> mTitleStr;
    private final LayoutInflater mInflater;
    private Context mContext;

    public MyChannelAdapter(Context context, List<Sub> mTitleStr) {
        this.mContext = context;
        this.mTitleStr = mTitleStr;
        mInflater = LayoutInflater.from(mContext);
    }

    @Override
    public int getCount() {
        return mTitleStr.size();
    }


    @Override
    public Object getItem(int position) {
        return mTitleStr.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View view, ViewGroup viewGroup) {
        //将布局文件转换成View
        View gridview_item = View.inflate(mContext, R.layout.layout_add_menus_type_item, null);
        TextView tv_channel = (TextView) gridview_item.findViewById(R.id.tv_channel);
        tv_channel.setText(mTitleStr.get(position).getName());
        return gridview_item;
    }


}
